﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ObjectInitializers
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Callate cabrona!");


            // Object initializer
            Rupia r = new Rupia() { Name = "Rosita", age = 21  , Pelos = 50  };
            Rupia r3 = new Rupia() { Name = "Yaquesita", age = 19 , Pelos = 3 };
            
            // a pelo
            Rupia r2 = new Rupia();
            r2.Name = "Marianela";
            r2.age = 19;

            var noobster = new { Name = "Tavo", r.age, money = 0 , sueldo = 10000.00 };

            Console.WriteLine("Tipo de noobster: "+noobster.GetType());


            Console.WriteLine(r.Name);
            Console.WriteLine(r2.Name);
            Console.WriteLine(r2.Pelos);
            Console.WriteLine("Como quisiera una" + r3.Name + " de " + r3.Pelos);
            Console.WriteLine("Un pichon: " + noobster.Name+"edad "+(noobster.age+1) );
            Console.Write("saca otra edad culons!: ");
            string line;
            int edades = int.Parse(line = Console.ReadLine());
            Console.WriteLine("edad SHuuky " + ((noobster.age+1) + edades));

            // Extension Methods
            Console.WriteLine("Hola, amigos".BetterToString());
            Console.WriteLine(StringHelper.BetterToString("Hola, amigos"));
            Console.WriteLine("yo se que es un chingo ".BetterToString() + " pero como hay que recivir aparte de nuestro premio de tenere trabajo");
            Console.WriteLine(" un sueldo de" + noobster.sueldo + " depero no se preocupen por que esto es " + noobster.sueldo.Muchachitos() );
            Console.WriteLine("ayayahiii que bueno soy con mis empleados ".BetterToString());

            // Generic type
            Stack<int> stack = new Stack<int>();
            stack.Push(5);
            stack.Push(10);
            int x = stack.Pop();        // x is 10
            int y = stack.Pop();        // y is 5

            Console.WriteLine("x:"+x);
            Console.WriteLine("y:" +y);

            Console.ReadKey();

        }
    }

    public class Stack<T>
    {
        int position;
        T[] data = new T[100];
        public void Push(T obj) { data[position++] = obj; }
        public T Pop() { return data[--position]; }
    }

    public static class StringHelper
    {
        public static string BetterToString(this string val)
        {
            return val.ToString() + "...mucho a la verga!";
        }
    }

    public static class ForMy
    {
        public static double Muchachitos(this double ratio)
            {
                return ratio = (ratio - (ratio * .79));
	            
            }
    }
    class Rupia
    {
        
        public int age;
        private bool employed;

        // Automagic properties
        public String Name { get; set; }
        public int Pelos { get; set; }

        // Constructor
        public Rupia()
        {
            employed = false;
        }
        
        public void hire(){
            employed = true;
        }

        public void fire()
        {
            employed = false;
        }

        public bool isEmployed()
        {
            return employed;
        }

    }
}
